package com.ruoyi.pom.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pom.domain.PomTasks;
import com.ruoyi.pom.service.IPomTasksService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * tasksController
 * 
 * @author ruoyi
 * @date 2025-01-10
 */
@RestController
@RequestMapping("/pom/tasks")
public class PomTasksController extends BaseController
{
    @Autowired
    private IPomTasksService pomTasksService;

    /**
     * 查询tasks列表
     */
    @PreAuthorize("@ss.hasPermi('pom:tasks:list')")
    @GetMapping("/list")
    public TableDataInfo list(PomTasks pomTasks)
    {
        startPage();
        List<PomTasks> list = pomTasksService.selectPomTasksList(pomTasks);
        return getDataTable(list);
    }

    /**
     * 导出tasks列表
     */
    @PreAuthorize("@ss.hasPermi('pom:tasks:export')")
    @Log(title = "tasks", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PomTasks pomTasks)
    {
        List<PomTasks> list = pomTasksService.selectPomTasksList(pomTasks);
        ExcelUtil<PomTasks> util = new ExcelUtil<PomTasks>(PomTasks.class);
        util.exportExcel(response, list, "tasks数据");
    }

    /**
     * 获取tasks详细信息
     */
    @PreAuthorize("@ss.hasPermi('pom:tasks:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pomTasksService.selectPomTasksById(id));
    }

    /**
     * 新增tasks
     */
    @PreAuthorize("@ss.hasPermi('pom:tasks:add')")
    @Log(title = "tasks", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PomTasks pomTasks)
    {
        return toAjax(pomTasksService.insertPomTasks(pomTasks));
    }

    /**
     * 修改tasks
     */
    @PreAuthorize("@ss.hasPermi('pom:tasks:edit')")
    @Log(title = "tasks", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PomTasks pomTasks)
    {
        return toAjax(pomTasksService.updatePomTasks(pomTasks));
    }

    /**
     * 删除tasks
     */
    @PreAuthorize("@ss.hasPermi('pom:tasks:remove')")
    @Log(title = "tasks", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pomTasksService.deletePomTasksByIds(ids));
    }
}
